package com.jxaummd.mushroom.main.user.item;

import android.view.View;
import android.widget.TextView;

import com.jxaummd.mushroom.R;
import com.jxaummd.mushroom.main.user.data.SingleTextListenerModel;
import com.jxaummd.mushroom.main.user.fragment.ListFragment;

import java.util.List;

import eu.davidea.flexibleadapter.FlexibleAdapter;
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem;
import eu.davidea.flexibleadapter.items.IFlexible;
import eu.davidea.viewholders.FlexibleViewHolder;

public class ListItem extends AbstractFlexibleItem<ListItem.ViewHolder> {
    private ListFragment.ListBean model = null;

    public ListItem(ListFragment.ListBean model) {
        this.model = model;
    }

    @Override
    public boolean equals(Object o) {
        return o.equals(this);
    }

    @Override
    public int getLayoutRes() {
        return R.layout.common_list_item;
    }

    @Override
    public ViewHolder createViewHolder(View view, FlexibleAdapter<IFlexible> adapter) {
        return new ViewHolder(view,adapter);
    }

    @Override
    public void bindViewHolder(FlexibleAdapter<IFlexible> adapter, ViewHolder holder, int position, List<Object> payloads) {
        holder.mTitle.setText(model.getTitle());
        holder.itemView.setOnClickListener(model.getListener());
        holder.mTitlDescrible.setText(model.getDescribe());
    }


    class ViewHolder extends FlexibleViewHolder {
        TextView mTitle = null;
        TextView mTitlDescrible = null;

        public ViewHolder(View view, FlexibleAdapter adapter) {
            super(view, adapter);
            mTitle=itemView.findViewById(R.id.tv_common_list_item_title);
            mTitlDescrible=view.findViewById(R.id.tv_common_list_item_describe);
        }
    }
}
